<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<!-- 审批流程页面 -->
<html lang="en">
<head>
		<base href="<%=basePath%>">
		<meta charset="utf-8" />
		<link rel="stylesheet" href="front/css/scrollBar.css">
	    <link rel="stylesheet" href="front/css/normal.css">
	    <link rel="stylesheet" href="front/content/css/projectAdm.css">
	    <style>
	    	.textalignLeft{
	    		text-align:left;padding-left:20px;
	    	}
	    </style>
</head>

<script type="text/javascript">
	function agree(){
		$('#flag').val('yes');
		$.ajax({
			type: "POST",
			url: $("#Form").attr("action"),
	    	data: $("#Form").serialize(),
			dataType:'json',
			cache: false,
			success: function(data){
				if(data.msg == "success"){
					alert("审批成功!");
					var iframe_id = $("#mainFrame",window.parent.document).contents().find("#page>iframe:visible")[0].getAttribute("id");
					var iframe_src = $("#mainFrame",window.parent.document).contents().find("#page>iframe:visible")[0].getAttribute("src");
					$("#mainFrame",window.parent.document).contents().find("#"+iframe_id)[0].setAttribute("src",iframe_src);
				}
			}
		});
	}
	
	function noagree(){
		$('#flag').val('no');
		$.ajax({
			type: "POST",
			url: $("#Form").attr("action"),
	    	data: $("#Form").serialize(),
			dataType:'json',
			cache: false,
			success: function(data){
				if(data.msg == "success"){
					alert("驳回成功!");
					var iframe_id = $("#mainFrame",window.parent.document).contents().find("#page>iframe:visible")[0].getAttribute("id");
					var iframe_src = $("#mainFrame",window.parent.document).contents().find("#page>iframe:visible")[0].getAttribute("src");
					$("#mainFrame",window.parent.document).contents().find("#"+iframe_id)[0].setAttribute("src",iframe_src);
				}
			}
		});
	}
</script>
<body style="box-shadow: none">

	<form action="applygoods/${msg}.do" name="Form" id="Form"
		method="post">
		<input type="hidden" name="apply_goods_id"
			id="apply_goods_id" value="${pd.apply_goods_id}" /> 
		<input type="hidden" name="user_id" id="user_id" value="${pd.user_id}"/>
		<input type="hidden" name="task_id" id="task_id" value="${act.taskId}"/>
		<input type="hidden" name="procIns_id" id="procIns_id" value="${act.procInsId}"/>
		<input type="hidden" name="flag" id="flag" value="${act.flag}"/>
		<input type="hidden" name="task_def_key" id="task_def_key" value="${act.taskDefKey}"/>
		<input type="hidden" name="apply_acount_price" id="apply_acount_price" value="${pd.apply_acount_price}"/>
		<div >
		<p class="con-title">采购申请详情</p>
        
        <table class='carInfoTable'>
        	<colgroup>
        		<col width='130'>
        		<col width='510'>
        		<col width='130'>
        		<col width='510'>
        	</colgroup>
        	<tr>
        		<td>申请人:</td>
        		<td class='textalignLeft'>${pd.USERNAME}</td>
        		<td>部门:</td>
        		<td class='textalignLeft'>${pd.department_name}</td>
        	</tr>
        	<tr>
        		<td>申请时间:</td>
        		<td class='textalignLeft'><fmt:formatDate value="${pd.create_time}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
        		<td>预算总金额:</td>
        		<td class='textalignLeft'>${pd.apply_acount_price}</td>
        	</tr>
        	<tr>
        		<td>物品信息</td>
        		<td colspan="3" class='textalignLeft'>
        			<c:choose>
					<c:when test="${not empty detailList}">
						<c:forEach items="${detailList}" var="var" varStatus="vs">
								${vs.index+1}.${var.goods_name}-单价${var.goods_price}-数量<font color="#FF0000">${var.goods_num}</font>
								-共${var.goods_account}元
								<c:if test="${pd.buy_state==2}">
									<br>实际购买-单价${var.reality_price}-数量<font color="#FF0000">${var.reality_num}</font>
									-共${var.reality_account}元-备注:${var.reality_remark}
								</c:if>
								<c:if test="${pd.putin_state==2}">
									<br>实际入库数量<font color="#FF0000">${var.put_num}</font>-入库备注:${var.putin_remark}
								</c:if>
								<br>
						</c:forEach>
					</c:when>
				</c:choose>
        		</td>
        	</tr>
        	<tr>
        		<td>申请时备注:</td>
        		<td colspan="3" class='textalignLeft'>${pd.remark}</td>
        	</tr>
        	<tr>
				<td >审批意见:</td>
				<td colspan="3" class='textalignLeft'><textarea name="comment" id="comment" rows="3" cols="100"></textarea></td>
			</tr>
        	<c:if test="${pd.buy_state==2}">
        	<tr>
        		<td>预计总金额:</td>
        		<td class='textalignLeft'>${pd.apply_acount_price}</td>
        		<td>附件:</td>
        		<td><a class="download operatea" href="${pd.attachment_path}">${pd.attachment_name}</a></td>
			</tr>
			</c:if>
        	
        </table>
        <p class="btn-box">
            <p class="btn-box">
        	<button onclick="agree();" class='bgcolor'>通过</button>
            <button onclick="noagree();" class='bgcolor'>驳回</button>
            <button onclick="javascript:history.back(-1);" class='graycolor'>返回</button>
        </p>
        </p>
    </div>
		
		<fieldset>
			<legend>流转信息</legend>
			<div id="histoicFlowList">
				<table class="table table-striped table-bordered table-condensed">
					<tr><th>执行环节</th><th>执行人</th><th>开始时间</th><th>结束时间</th><th>提交意见</th><th>任务历时</th></tr>
					<c:forEach items="${varList}" var="act">
						<tr>
							<td>${act.histIns.activityName}</td>
							<td>${act.assigneeName}</td>
							<td><fmt:formatDate value="${act.histIns.startTime}" type="both"/></td>
							<td><fmt:formatDate value="${act.histIns.endTime}" type="both"/></td>
							<td style="word-wrap:break-word;word-break:break-all;">${act.comment}</td>
							<td>${act.durationTime}</td>
						</tr>
					</c:forEach>
				</table>
			</div>
		</fieldset>
	</form>


	<!-- 引入 -->
	<script type="text/javascript">
		window.jQuery
				|| document
						.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");
	</script>
	<script src="static/js/bootstrap.min.js"></script>
	<script src="static/js/ace-elements.min.js"></script>
	<script src="static/js/ace.min.js"></script>
	<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script>
	<!-- 下拉框 -->
	<script type="text/javascript"
		src="static/js/bootstrap-datepicker.min.js"></script>
	<!-- 日期框 -->
	<script type="text/javascript">
		$(top.hangge());
		$(function() {

			//单选框
			$(".chzn-select").chosen();
			$(".chzn-select-deselect").chosen({
				allow_single_deselect : true
			});

			//日期框
			$('.date-picker').datepicker();

		});
	</script>
</body>
</html>